package com.three.storemanage.controller;

import com.three.core.entity.CarStore;
import com.three.core.entity.CarWashRecord;
import com.three.core.entity.WashCarCoupon;
import com.three.core.vo.R;
import com.three.storemanage.service.CarWashRecordService;
import com.three.storemanage.vo.CouponVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @FileName: CarStoreController
 * @Description:
 * @Author: GYX
 * @CreateTime: 2025/3/17 19:41
 * @Version: 1.0.0
 */
@RestController
@RequestMapping("/store/washrecord")
public class CarStoreController {
    @Autowired
    private CarWashRecordService carStoreService;

    @GetMapping("/selectRecord")
    public R<List<CarWashRecord>> selectRecord(Integer storeId){
        return carStoreService.selectByStoreId(storeId);
    }

    @GetMapping("/selectNumByUserId")
    public R<List<CarWashRecord>> selectRecordByUserId(){
        return carStoreService.selectByUserId();
    }

    @GetMapping("/countByUserId")
    public R<Integer> countByUserId(Integer userId){
        return carStoreService.countByUserId(userId);
    }

    @PostMapping("/selectRecordByUserId")
    public R<List<CarWashRecord>> selectRecordByDate(
            @RequestParam Integer userId,
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date createDate) {
        return carStoreService.selectByUserIdAndDate(userId, createDate);
    }

    @PostMapping("/insertCarWahRecord")
    public R<Integer> insertCarWashRecord(@RequestBody CarWashRecord carWashRecord) {
        return carStoreService.insertCarWashRecord(carWashRecord);
    }

    @PostMapping("/selectCouponByCouponVo")
    public R<List<WashCarCoupon>> selectCouponByCouponVo(@RequestBody CouponVo couponVo) {
        return carStoreService.selectCouponByCondition(couponVo);
    }

    @PostMapping("/payCarMoney")
    public R<Integer> payCarMoney(@RequestBody CarWashRecord carWashRecord) {
        return carStoreService.updateCarWashRecord(carWashRecord);
    }

}
